package com.wsoft.hr.pm.controller;

import com.github.pagehelper.PageInfo;
import com.wsoft.hr.pm.entity.HrPmGradeMemberCycleEntity;
import com.wsoft.hr.pm.query.grade.member.cycle.HrPmGradeMemberCycleInsertQuery;
import com.wsoft.hr.pm.query.grade.member.cycle.HrPmGradeMemberCycleListQuery;
import com.wsoft.hr.pm.query.grade.member.cycle.HrPmGradeMemberCycleUpdateQuery;
import com.wsoft.hr.pm.service.IHrPmGradeMemberCycleService;
import com.wsoft.response.ResponsePage;
import com.wsoft.response.ResponseResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 评级人员周期表 Controller
 *
 * @Author Z001
 * @Date 2025-03-01 08:35:23
 */
@RestController
@Tag(name = "评级人员周期表")
@RequestMapping("/hrPmGradeMemberCycle")
public class HrPmGradeMemberCycleController {

    @Resource
    private IHrPmGradeMemberCycleService hrPmGradeMemberCycleService;

    @Operation(summary = "评级人员周期表-分页查询", description = "评级人员周期表 -分页查询")
    @PostMapping("/list")
    public ResponseResult list(@RequestBody @Valid HrPmGradeMemberCycleListQuery query) {
        PageInfo<HrPmGradeMemberCycleEntity> page = hrPmGradeMemberCycleService.listHrPmGradeMemberCycle(query);
        return ResponseResult.success(ResponsePage.restPage(page));
    }

    @Operation(summary = "评级人员周期表-详情", description = "评级人员周期表-详情")
    @GetMapping("/get")
    public ResponseResult get(@RequestParam("id") Long id) {
        return ResponseResult.success(hrPmGradeMemberCycleService.getInfo(id));
    }

    @Operation(summary = "新增-评级人员周期表", description = "新增-评级人员周期表")
    @PostMapping("/insert")
    public ResponseResult insert(@RequestBody @Valid HrPmGradeMemberCycleInsertQuery query) {
        boolean b =  hrPmGradeMemberCycleService.insertHrPmGradeMemberCycle(query);
        if (b) {
            return ResponseResult.success("[sys.msg.success]");
        } else {
            return ResponseResult.failed("[sys.msg.failed]");
        }
    }

    @Operation(summary = "更新-评级人员周期表", description = "更新-评级人员周期表")
    @PostMapping("/update")
    public ResponseResult update(@RequestBody @Valid HrPmGradeMemberCycleUpdateQuery query) {
        boolean b =  hrPmGradeMemberCycleService.updateHrPmGradeMemberCycle(query);
        if (b) {
            return ResponseResult.success("[sys.msg.success]");
        } else {
            return ResponseResult.failed("[sys.msg.failed]");
        }
    }

    @Operation(summary = "删除-评级人员周期表",description = "删除-评级人员周期表")
    @GetMapping("/delete")
    public ResponseResult delete(@RequestParam("id") Long id) {
        boolean b = hrPmGradeMemberCycleService.delete(id);
        if (b) {
            return ResponseResult.success("[sys.msg.success]");
        } else {
            return ResponseResult.failed("[sys.msg.failed]");
        }
    }
}
